.kanban-board
  = stylesheet_link_tag 'kanban', :plugin => 'ekanban'
  = link_to l(:label_kanban_setup), edit_project_kanban_path(@project.id,kanban.id), :class => 'icon icon-setup', :style => 'float:right'
  = link_to l(:label_kanban_report), {:controller => "kanban_reports", :action => "index", :project_id => @project.id}, :class => 'icon icon-report', :style => 'float:right'

  = search_field_tag "cards_per_column_#{kanban.id}", "", :class => "small cards-per-column", :style=>"float:right;width:20px",:selector=>"#kanban_#{kanban.id}"
  = label_tag "pane width:", "  Cards Per Row:", :style => "float:right;margin-top:5px;margin-left:10px;margin-right:1px", :title => "How many cards each row shown in a pane"
  = search_field_tag "kanban-search", "", :class => "small find-card", :style=>"float:right;width:150px",:selector=>"#kanban_#{kanban.id}"
  = label_tag "search card:", "Find:",:style => "float:right;margin-top:5px;margin-right:5px"
  %h3{:style => "margin-top:20px"}= kanban.name
  - panes = controller.panes(kanban)
  - panes_num = panes.size
  %table.kanban{:id=>"kanban_#{kanban.id}"}
    - if panes_num > 0
      %tr{:style=>"height:30px"}
        - stages = controller.stages_and_panes(panes)
        - stages.each do |s|
          - if s[:panes].size == 1
            %th{:id=>"stage_#{s[:stage].id}", :rowspan=>"2", :name=>s[:panes].first.name}
              .plain-text{:style => "width:80%;float:left"}
                = s[:stage].name
                %span.wip-text{:id => "wip_#{s[:stage].id}"}= " "
                /%span.ui-icon.ui-icon-minus{:style=>"float:right;width:8px;height:8px"}
              .menu-icon{:style=>"position:relative"}
                .ui-icon-triangle-1-s.ui-icon{:style=>"position:absolute;left:80%"}
                %ul.menu-holder{:style=>"display:none"}
                  %li{:id=>"li_collapse_all_#{s[:panes].first.id}"}
                    %a
                      %span.ui-icon.ui-icon-minus.menu-icon{:title=>"Collapse All"}
                      .menu-text Collapse All
                  - if KanbanWorkflow.transition_allowed?(s[:states].first,KanbanState.close_state(kanban),kanban.id)
                    %li{:id=>"li_check_all_#{s[:panes].first.id}"}
                      %a
                        %span.ui-icon.ui-icon-check.menu-icon{:title=>"Check All"}
                        .menu-text Check All
                    %li{:id=>"li_close_#{s[:panes].first.id}"}
                      %a
                        %span.ui-icon.ui-icon-seek-end.menu-icon{:title=>"Close Selected"}
                        .menu-text Close Selected
          - else
            %th{:id=>"stage_#{s[:stage].id}", :colspan=>"#{s[:panes].size}", :name=>s[:stage].name}
              =s[:stage].name
              %span.wip-text{:id => "wip_#{s[:stage].id}"}= "  "
      %tr
        - stages.each do |s|
          - if s[:panes].size > 1
            - s[:panes].each do |pane|
              %th{:id=>"pane_#{pane.name}"}
                .plain-text{:style => "width:80%;float:left"}=pane.name
                .menu-icon{:style=>"position:relative"}
                  .ui-icon-triangle-1-s.ui-icon{:style=>"position:absolute;left:80%"}
                  %ul.menu-holder{:style=>"display:none"}
                    %li{:id=>"li_collapse_all_#{pane.id}"}
                      %a
                        %span.ui-icon.ui-icon-minus.menu-icon{:title=>"Collapse All"}
                        .menu-text Collapse All
                    - if KanbanWorkflow.transition_allowed?(pane.kanban_state, KanbanState.close_state(kanban),kanban.id)
                      %li{:id=>"li_check_all_#{pane.id}"}
                        %a
                          %span.ui-icon.ui-icon-check.menu-icon{:title=>"Check All"}
                          .menu-text Check All
                      %li{:id=>"li_close_#{pane.id}"}
                        %a
                          %span.ui-icon.ui-icon-seek-end.menu-icon{:title=>"Close Selected"}
                          .menu-text Close Selected
      %tr{:style=>"height:90%; overflow-y:auto"}
        - panes.inject(0) do |i,pane|
          - if pane.kanban_state.is_closed == false
            %td.kanban-pane{:id=>"pane_#{pane.id}",:state_id=>"#{pane.kanban_state_id}",:role_id=>"#{pane.role_id}",:check_wip=>"#{pane.in_progress}"}
              - if pane.kanban_state.is_initial == true
                %input#backlog-search.small{:type=>"text",:style=>"display:none;width:90%;margin:0px;align:center"}
              = render :partial => "kanban_pane", :locals=>{:kanban_id => kanban.id, :pane_id => pane.id}

  = content_tag "div", "", :id => "kanban-panes-data", :data => {:panes => panes.to_json}


= javascript_include_tag "kanban", :plugin => :ekanban
:javascript
  $(function() {
    $.ajax({
      type: "GET",
      url:  "#{project_kanban_kanban_panes_path(params[:project_id],kanban.id)}",
      dataType: "json",
      cache: false,
      success: function(json){
        init_wip("#{kanban.id}", json);
      }
    });
  });
%style{:type => "text/css"}

